import router from "@/router"
import { useUserStore } from "@/store/index"

export function quit(before?: () => void, after?: () => void) {
    const store = useUserStore()
    before && before()
    localStorage.removeItem("token")
    // 清路由
    store.routes.forEach((item) => {
        console.log(item, item.name);
        router.removeRoute(item.name);
    });
    // 清除pinia
    store.username = ""
    store.menus = []
    // 跳转到登录页
    router.push("/login")
    after && after()
}